﻿using System;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace JQMergeFramework
{
    public class UnLockNewCity: MonoBehaviour
    {
        public Transform titleTrans;
        public Text lvTxt;
        
        public void Open(int lv,Action call = null)
        {
            GetComponent<UIPopAnimate>()?.PopStart();
            
            // titleTrans.localScale = new Vector3(0, 1, 1);
            //
            // lvTxt.color = new Color32(255, 252, 32, 0);
            // titleTrans.DOScale(Vector3.one, 0.2f).OnComplete(() =>
            // {
            //     lvTxt.DOColor(new Color32(255, 252, 32, 255), 0.5f);
            // });

            lvTxt.text = string.Format("恭喜获得Lv.{0}建筑", lv + 1);
            UICityCamera.I.ShowCityNode(lv,call);
            CommonFun.DelayCallback(() =>
            {
                GetComponent<UIPopAnimate>().PopEnd();
                
                UICityCamera.I.HideCityNode();
                call?.Invoke();
            },2F).Forget();
        }

    }
}